#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from lj_api.tool_flask import get_merge_param
from lj_tool.tool_log import log
from flask import Blueprint
from lj_action.factory_actions import lj_fas

api_action = Blueprint('action', __name__)


@api_action.route('/<action>/<dataCode>', methods=['GET', 'POST'])
def distribution(action, dataCode):
    log.info('访问api[%s - %s]' % (action, dataCode))

    res = lj_fas.get(action)({
        'data_code': dataCode,
        'data': get_merge_param(),
    }) or 'ok'

    if isinstance(res, int):
        res = str(res)

    return res
